<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>上传Excel</title>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/reset.css">
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.min.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.timer.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/common.js"></script>
<script type="text/javascript">
	$(function(){
		var UPLOAD_PATH = '{$UPLOAD_PATH}';
		window.dealSelectFile = function(data){
			var html = '<input type="hidden" value="'+UPLOAD_PATH+data.filekey+'" id="fileurl"/>文件地址：'+UPLOAD_PATH+data.filekey;		
			$('#result').html(html);
		}
	});
</script>
<style type="text/css">
	#upload_frame {
		width:204px;
		height:32px;
		margin-top:5px;
	}
	
	.myForm {
		margin-top:40px;
	}
	.myForm .deep {
		background-color:#F8F8F8;
	}
	.myForm dl {
		line-height:40px;
	}
	.myForm dl dt {
		width:160px;
		float:left;
		text-align:center;
	}
	.myForm dl dd {
		width:600px;
		float:left;
		text-align:left;
	}
	.myForm .filecontent dt {
		float:none;
		background-color:#CCC;
		text-align:center;
		width:auto;
	}
	.myForm .filecontent dd {
		float:none;
		width:auto;
	}
	.btn_import {
		width:200px;
		line-height:22px;
		padding:5px 0px;
		text-align:center;
		display:inline-block;
		background-color:#090;
		color:#FFF;
		cursor:pointer;
		margin-top:5px;
	}
	.filecontent {
		line-height:20px;
		padding:5px;
	}
</style>
</head>

<body>
	<div class="myForm clearfix">
		<dl class="clearfix">
			<dt>所属城市：</dt>
			<dd>
				<select class="filecontent" name="cityid" id="cityid">
					<option value="">请选择所属城市</option>
					<volist name="list" id="v">
						<option value="{$key}">{$v[1]}</option>
					</volist>
				</select>
			</dd>
		</dl>
		<dl class="clearfix deep">
			<dt>上传文件：</dt>
			<dd><iframe id="upload_frame" src="rest.php?s=FIL/Index/onefile&filetype=File" frameborder="0"></iframe></dd>
		</dl>
		<dl class="clearfix">
			<dt>文件名称：</dt>
			<dd class="filename" id="result">还未上传</dd>
		</dl>	
		<dl class="clearfix deep">
			<dt>导入文件：</dt>
			<dd>
				<span class="btn_import">立即导入</span>
			</dd>
		</dl>
		<dl class="clearfix">
			<dt>导入结果：</dt>
			<dd id="imResult"></dd>
		</dl>
	</div>
<script type="text/javascript">
	var api = frameElement.api, W = api.opener;
	$(function(){		
		$('.btn_import').on('click',function(){

			var fileurl = $('#fileurl').val();
			var cityid  = $('#cityid').val();

			$.post('__URL__/import/',{fileurl:fileurl,cityid:cityid},function(data){
				if(data.status == 0){
					$('#imResult').html('导入失败');
				}else{
					$('#imResult').html('导入成功，成功导入了['+data.addnum+']条数据');
					
					var obj = windowApi.lhgdialog.list['Custom_index'];
					obj.reload(obj);
					frameApi.close(); //关闭当前窗口
				}
			},'json');		
		});
	});
</script>
</body>
</html>
